# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rr
_gemname=rr
pkgver=3.0.9
pkgrel=0
pkgdesc="Test double framework that features a rich selection of double techniques"
url="https://github.com/rr/rr"
arch="noarch"
license="MIT"
depends="ruby"
checkdepends="
	ruby-minitest
	ruby-test-unit
	ruby-test-unit-rr
	"
makedepends="ruby-rdoc"
subpackages="$pkgname-doc"
source="https://github.com/rr/rr/archive/v$pkgver/$_gemname-$pkgver.tar.gz
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"
options="!check"  # avoid circular dependency with ruby-test-unit-rr

build() {
	gem build $_gemname.gemspec
}

check() {
	RR_INTEGRATION=minitest ruby test/run-test.rb
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"

	gem install \
		--local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--document ri \
		--verbose \
		$_gemname

	# Remove unnessecary files
	cd "$gemdir"
	rm -rf build_info cache extensions plugins
}

doc() {
	pkgdesc="$pkgdesc (ri docs)"

	amove "$(ruby -e 'puts Gem.default_dir')"/doc
}

sha512sums="
df285aa1c9c226765f33338ad267abfded568bfc2b76d7d966e20b68d849f071c2a3e3a6a666c70584993d26956a7ae0ccca8be68a66a862826c9203b0e04ee9  rr-3.0.9.tar.gz
e8d2ee005b6cab9ff0abedb3611bf7b5292e8526aa9cac5957284f57d68790fe98c5d95b51517a27102923f36e846c57fdc74ae73e618e5d066b376edc6994c7  gemspec.patch
"
